home *** CD-ROM | disk | FTP | other *** search
- { This code is hereby released to the Public Domain }
- { by Dan Thomas 1991 Compuserve 72301,2164 Prodigy CWRF01A }
-
- LIBRARY DllDialg;
- {**********************************************************************}
- {* DllDialg by Dan Thomas *}
- {* *}
- {* Shows how to run a dialog from a DLL *}
- {**********************************************************************}
-
- USES WinTypes, WObjects, WinProcs, Strings;
-
- {$R DllDialg.res}
-
- var
- MsgText,
- ResultText: string;
- ResultSize: integer;
- MyInstance: tHandle;
-
-
- {**********************************************************************}
- {* Dialog procedure used by DialogBox *}
- {**********************************************************************}
- FUNCTION DllDialogProc(Dlg: hWnd; msg: word; wParam: word; lParam: longint): bool; export;
-
- begin
- DllDialogProc := false;
- case msg of
- wm_InitDialog : begin
- SetDlgItemText(Dlg,101,@MsgText[1]);
- SetDlgItemText(Dlg,102,@ResultText[1]);
- DllDialogProc := true;
- end;
- wm_Command : if wParam = id_OK then
- begin
- GetDlgItemText(Dlg,102,@ResultText[1],ResultSize);
- EndDialog(Dlg,1);
- DllDialogProc := true;
- end
- else
- if wParam = id_Cancel then
- begin
- EndDialog(Dlg,0);
- DllDialogProc := true;
- end;
- end; {of case}
- end; {DllDialogProc}
-
- {**********************************************************************}
- {* Function that you call: *}
- {**********************************************************************}
- FUNCTION DllDialog(aMsgText,aResultText: pChar; aResultSize: integer): word; export;
-
- var
- w : word;
- MyProc : tFarProc;
-
- begin
- DllDialog := 1;
- MsgText := StrPas(aMsgText)+#00;
- ResultText := StrPas(aResultText)+#00;
- ResultSize := aResultSize;
- MyProc := MakeProcInstance(@DllDialogProc,MyInstance);
- w := DialogBox(MyInstance,'DLLDIALG',0,MyProc);
- FreeProcInstance(MyProc);
- if w = id_OK then
- StrPCopy(aResultText,ResultText);
- DllDialog := w;
- end; {DllDialog}
-
- exports DllDialog index 1;
-
- begin
- MyInstance := system.hInstance;
- end.